#pragma once

#include <QString>
#include <QList>
#include <QDebug>
#include <QImage>

enum ImgVersionEnum {
    Other = 0x00,
    Ver1 = 0x01,
    Ver2 = 0x02,
    Ver4 = 0x04,
    Ver5 = 0x05,
    Ver6 = 0x06,
    Ver7 = 0x07,
    Ver8 = 0x08,
    Ver9 = 0x09
};

enum SpriteTypeEnum {
    UnknownSpriteType = 0x00,
    Argb1555 = 0x0e,
    Argb4444 = 0x0f,
    Argb8888 = 0x10,
    Link = 0x11,
    Dxt1 = 0x12,
    Dxt3 = 0x13,
    Dxt5 = 0x14
};

enum CompressModeEnum {
    UnknownCompressMode = 0x01,
    Zlib = 0x06,
    None = 0x05,
    DdsZlib = 0x07,
};

struct SpriteStruct {
    int Index = 0;
    SpriteTypeEnum Type = SpriteTypeEnum::UnknownSpriteType;
    int LinkIndex = 0;
    CompressModeEnum CompressMode = CompressModeEnum::UnknownCompressMode;
    int Width = 0;
    int Height = 0;
    int Length = 0;
    int X = 0;
    int Y = 0;
    int FrameWidth = 0;
    int FrameHeight = 0;
    long long DataOffset;
};

struct Album {
    int Offset = 0;
    int Length = 0;
    QString Path;
    long long IndexLength = 0;
    ImgVersionEnum Version = Other;
    int Count = 0;
    QList<QList<QColor>> ColorLists;
    QByteArray SpritesDataBa;
    QList<SpriteStruct> SpriteList;
};

char ReadByteFromDataStream(QDataStream *streamPtr);
void ReadAllFromDataStream(QDataStream *streamPtr, QByteArray &ba);
QByteArray ReadFromDataStream(QDataStream *streamPtr, uint len);
int ReadInt(QDataStream *streamPtr);
long long ReadLongLong(QDataStream *streamPtr);
void GetImgFromUCharArray(QImage &img, int w, int h, uchar * const data, int dataLength, SpriteTypeEnum type);
